package com.xxmw.transaction.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;

@Getter
@Setter
public class ScheduleJob implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 任务调度参数key
     */
    public static final String JOB_PARAM_KEY = "JOB_PARAM_KEY";

    @TableId(type = IdType.AUTO)
    private Long jobId;

    /**
     * 交易所
     */
    private Integer bourse;

    /**
     * 交易对
     */
    private String symbol;

    /**
     * 定时任务类型
     * {@link JobType}
     */
    private Integer type;

    @NotBlank(message = "bean名称不能为空!")
    private String beanName;

    @NotBlank(message = "方法名称不能为空")
    private String methodName;

    private String params;

    @NotBlank(message = "cron表达式不能为空")
    private String cron;

    private Integer status;

    private String remark;

    private Date created;

    public enum JobType {

        system(1, "系统任务"),
        ROBOT(2, "机器人任务");

        private int value;

        private String desc;

        JobType(int value, String desc) {
            this.value = value;
            this.desc = desc;
        }

        public int getValue() {
            return value;
        }

        public String getDesc() {
            return desc;
        }
    }

}
